<template>
  <div class="examination">
    <div class="box-card-father">
      <el-card class="box-card" v-for="(item,index) in question">
        <div class="box-card-item1">
          <el-image :src="urls" class="paper-image"/>
        </div>
        <div class="box-card-item2" @click="goToTest(item.exampageId)">
          <div>{{item.exampageName}}</div>
          <div>开始做题</div>
          <div>开始时间:{{item.startTime}}</div>
          <div>结束时间:{{item.endTime}}</div>
        </div>
      </el-card>
    </div>
    <div class="page">
      <el-pagination :page-size="size" layout="prev, pager, next" :total="total" class="page-item"
                     @current-change="pageTo"/>
    </div>
  </div>
</template>

<script>
  import questions from "../../utils/question"
  import {EnterAbleExam} from "../../api";

  export default {
    name: "examination",
    data() {
      return {
        urls: require("../../assets/paper.png"),
        question: [],
        //试卷总数
        total: 0,
        //试卷个数
        size: 6,
      }
    },
    methods: {
      pageTo(data) {
        console.log(data);
      },
      goToTest(question) {
        console.log(question);
        this.$router.replace({path: '/test', query: {question: question}});
      },
      async enterAbleExam() {
        await EnterAbleExam({current: 1, size: 9, id: this.$store.state.user.userId}).then((res) => {
          console.log(res);
          this.total = res.data.total;
          this.question = [...res.data.record];
        }).catch((err) => {
          console.log(err);
        })
      }
    },
    created() {
      // this.getPaper();
      this.enterAbleExam()
    }
  }
</script>

<style scoped>
  .examination {
    margin-bottom: 10px;
  }

  .box-card-father > .box-card {
    display: inline-block;
  }

  .box-card:hover {
    cursor: pointer;
  }

  .box-card {
    width: 28%;
    margin-left: 3.7%;
    margin-top: 3%;
  }

  .box-card-item1, .box-card-item2 {
    width: 50%;
    display: inline-block;
    vertical-align: middle;
  }

  .box-card-item2 {
    font-size: 20px;

  }

  .box-card-item2 > div {
    margin-top: 10px;
  }

  .box-card-item2 > div:nth-child(3), .box-card-item2 > div:nth-child(4) {
    font-size: 12px;
  }


  @media screen and (max-width: 768px) {
    .box-card {
      width: 95%;
    }

    .page {
      width: 5%;
    }
  }

  @media screen and (min-width: 768px) and (max-width: 1200px) {
    .box-card {
      width: 45%;
    }
  }

  @media screen and (min-width: 1200px) {
    .box-card {
      width: 28%;
    }
  }

  .page {
    margin-top: 10px;
    width: 8%;
  }


</style>
